
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="page/head.jsp" %>
<html>
<head>
    <title>Title</title>
</head>


<body>
<div class="container">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <form action="/emp/updateEmp" method="post">
                <div class="form-group">
                    <label for="ename">员工们</label>
                    <input type="hidden" name="eno" value="${e.eno}">
                    <input type="text" class="form-control" id="ename" name="ename" value="${e.ename}"
                           placeholder="ename">
                    <span id="msg"></span>
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword1">密码</label>
                    <input type="password" class="form-control" id="exampleInputPassword1" name="pwd" value="${e.pwd}"
                           placeholder="Password">
                </div>
                <div class="form-group">
                    <label>性别</label>
                    <label class="radio-inline">

                        <input type="radio" name="esex" ${e.esex=='男'?"checked":""} value="男">男

                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="esex" ${e.esex=='女'?"checked":""} value="女">女
                    </label>
                </div>
                <div class="form-group">
                    <label for="salary">工资</label>
                    <input type="number" class="form-control" id="salary" name="salary" value="${e.salary}"
                           placeholder="salary">
                </div>
                <div class="form-group">
                    <label for="salary">部门</label>
                    <input type="hidden" id="userdno" value="${e.dno}">
                    <select name="dno" id="dno">

                    </select>
                </div>
                <div class="form-group">
                    <label for="date">出生日期</label>
                    <input type="date" class="form-control" id="date" name="birthday"
                           value="<fm:formatDate value='${e.birthday}' pattern='yyyy-MM-dd'/>">
                </div>
                <button type="submit" class="btn btn-default" id="btn1" >修改</button>
            </form>
        </div>
    </div>
</div>
<script>
    $(function () {
        $.ajax({
            url: "/dept/getAll",
            type: "get",
            dataType: "json",
            success: function (result) {
                var dno = $("#userdno").val();
                for (let x in result) {
                    if (dno == result[x].dno) {
                        $("#dno").append("<option selected value='" + result[x].dno + "'>" + result[x].dname + "</option>")
                    } else {
                        $("#dno").append("<option value='" + result[x].dno + "'>" + result[x].dname + "</option>")
                    }
                }
            }
        })

    })
</script>
</body>
</html>
